<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" 
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录 - 校园二手书交易平台</title>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .login-container {
            max-width: 400px;
            margin: 3rem auto;
        }
        .login-card {
            border-radius: 5px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }
        .form-control {
            border-radius: 3px;
            padding: 10px 15px;
        }
        .login-btn {
            padding: 8px 16px;
            font-weight: 500;
        }
        .toggle-password {
            cursor: pointer;
        }
        .login-title {
            color: #495057;
            font-size: 1.5rem;
        }
        .footer {
            margin-top: 30px;
            font-size: 0.9rem;
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" th:href="@{/}">校园二手书交易平台</a>
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav mr-auto">
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/}"><i class="fas fa-home"></i> 首页</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/book/list}"><i class="fas fa-book"></i> 书籍列表</a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item active">
                        <a class="nav-link" th:href="@{/login}"><i class="fas fa-sign-in-alt"></i> 登录</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 登录表单 -->
    <div class="container login-container">
        <div class="card login-card bg-white">
            <div class="card-body p-4">
                <h3 class="login-title text-center mb-4"><i class="fas fa-sign-in-alt mr-2"></i>账号登录</h3>

                <!-- 提示消息 -->
                <div th:if="${param.error}" class="alert alert-danger">
                    <small><i class="fas fa-exclamation-circle"></i> 用户名或密码错误</small>
                </div>
                <div th:if="${param.logout}" class="alert alert-success">
                    <small><i class="fas fa-check-circle"></i> 您已成功退出登录</small>
                </div>

                <!-- 登录表单 -->
                <form th:action="@{/login}" method="post">
                    <!-- 用户名 -->
                    <div class="form-group">
                        <label for="username">用户名</label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="fas fa-user"></i></span>
                            </div>
                            <input type="text" class="form-control" id="username" name="username" placeholder="请输入用户名" required>
                        </div>
                    </div>

                    <!-- 密码 -->
                    <div class="form-group">
                        <label for="password">密码</label>
                        <div class="input-group">
                            <div class="input-group-prepend">
                                <span class="input-group-text"><i class="fas fa-lock"></i></span>
                            </div>
                            <input type="password" class="form-control" id="password" name="password" placeholder="请输入密码" required>
                            <div class="input-group-append">
                                <span class="input-group-text toggle-password">
                                    <i class="fas fa-eye"></i>
                                </span>
                            </div>
                        </div>
                    </div>

                    <!-- 记住我 -->
                    <div class="form-group">
                        <div class="custom-control custom-checkbox">
                            <input type="checkbox" class="custom-control-input" id="remember-me" name="remember-me">
                            <label class="custom-control-label" for="remember-me">记住我</label>
                        </div>
                    </div>

                    <!-- 登录按钮 -->
                    <div class="form-group">
                        <button type="submit" class="btn btn-success btn-block login-btn">
                            <i class="fas fa-sign-in-alt mr-2"></i>登录
                        </button>
                    </div>
                </form>

                <!-- 链接区域 -->
                <div class="d-flex justify-content-between mt-3">
                    <small><a th:href="@{/user/forgot-password}" class="text-muted"><i class="fas fa-key mr-1"></i>忘记密码?</a></small>
                    <small><a th:href="@{/user/register}" class="text-success"><i class="fas fa-user-plus mr-1"></i>注册新账号</a></small>
                </div>
            </div>
        </div>

        <!-- 页面底部信息 -->
        <div class="text-center footer text-muted">
            <p>&copy; 2023 校园二手书交易平台</p>
        </div>
    </div>

    <!-- JavaScript -->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.bundle.min.js"></script>
    <script>
        $(document).ready(function() {
            // 密码显示/隐藏
            $('.toggle-password').click(function() {
                const passwordInput = $(this).closest('.input-group').find('input');
                const icon = $(this).find('i');
                
                if (passwordInput.attr('type') === 'password') {
                    passwordInput.attr('type', 'text');
                    icon.removeClass('fa-eye').addClass('fa-eye-slash');
                } else {
                    passwordInput.attr('type', 'password');
                    icon.removeClass('fa-eye-slash').addClass('fa-eye');
                }
            });

            // 自动关闭提示框
            setTimeout(function() {
                $('.alert').alert('close');
            }, 3000);
        });
    </script>
</body>
</html> 